package com.itheima.jf.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 放行静态资源
 *
 * @Author Vsunks.v
 * @Blog blog.sunxiaowei.net/996.mba
 * @Description: 放行静态资源
 */
@Component
public class SpringMVCSupport extends WebMvcConfigurationSupport {
    /**
     * 通过形参给定的registry去指定哪些请求需要放行（静态资源需要放行）
     * 直接由Tomcat处理
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {


        registry.
                // 指定哪些请求，/pages/* 表示pages下面的一级请求
                // /pages/** 表示pages下面的多级请求
                addResourceHandler("/pages/**")
                // 映射到哪些静态资源
                .addResourceLocations("/pages/");
        registry.addResourceHandler("/css/**").addResourceLocations("/css/");
        registry.addResourceHandler("/js/**").addResourceLocations("/js/");
        registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");

    }
}
